<?php

class Queueds
{

    public function send($sendMsg){
        $connection = new \PhpAmqpLib\Connection\AMQPStreamConnection('127.0.0.1', 5672, 'guest', 'guest');
        $channel = $connection->channel();
        // 定义队列
        $channel->queue_declare('first', false, true,false, false);
        $msg = new \PhpAmqpLib\Message\AMQPMessage(
            json_encode($sendMsg),
            // 确保消息不丢失
            array('delivery_mode' => \PhpAmqpLib\Message\AMQPMessage::DELIVERY_MODE_PERSISTENT)
        );
        $channel->basic_publish($msg, '','first');
        $channel->close();
        $connection->close();
    }
}
